const {
  req
} = require('../../utils/requests')

Page({

  data: {
    scheduleList: [{
        "date": "今天 星期五",
        "todayFixture": [{
            "time": "07:30",
            "homeField": "76 人（2）",
            "awayField": "篮 网（0）",
            "homeIcon": "sixers",
            "awayIcon": "net",
            "fieldText": "",
            "isVIP": true,
            "dieldState": "回放"
          },
          {
            "time": "10:00",
            "homeField": "",
            "awayField": "",
            "fieldText": "76人vs篮网 赛后新闻发布会",
            "isVIP": false,
            "dieldState": "回放"
          },
          {
            "time": "10:00",
            "homeField": "国王（2）",
            "awayField": "勇士（1）",
            "homeIcon": "kings",
            "awayIcon": "warriors",
            "fieldText": "",
            "isVIP": false,
            "dieldState": "正在直播"
          },
          {
            "time": "10:30",
            "homeField": "太阳（1）",
            "awayField": "快船（1）",
            "homeIcon": "suns",
            "awayIcon": "clippers",
            "fieldText": "",
            "isVIP": true,
            "dieldState": "视频直播"
          },
          {
            "time": "12:30",
            "homeField": "",
            "awayField": "",
            "fieldText": "国王vs勇士 赛后新闻发布会",
            "isVIP": false,
            "dieldState": "视频直播"

          },
          {
            "time": "13:00",
            "homeField": "",
            "awayField": "",
            "fieldText": "太阳vs快船 赛后新闻发布会",
            "isVIP": false,
            "dieldState": "视频直播"
          }
        ]
      },
      {
        "date": "04月22日星期六",
        "todayFixture": [{
            "time": "07:00",
            "homeField": "凯尔特人（2）",
            "awayField": "老鹰（0）",
            "homeIcon": "celtics",
            "awayIcon": "hawks",
            "fieldText": "",
            "isVIP": false,
            "dieldState": "视频直播"

          },
          {
            "time": "08:30",
            "homeField": "骑士（1）",
            "awayField": "尼克斯（1）",
            "homeIcon": "cavaliers",
            "awayIcon": "knicks",
            "fieldText": "",
            "isVIP": true,
            "dieldState": "视频直播"

          },
          {
            "time": "09:30",
            "homeField": "",
            "awayField": "",
            "fieldText": "凯尔特vs老鹰 赛后新闻发布会",
            "isVIP": true,
            "dieldState": "视频直播"
          },
          {
            "time": "09:30",
            "homeField": "掘金（2）",
            "awayField": "森林狼（0）",
            "homeIcon": "nuggets",
            "awayIcon": "timberwolves",
            "fieldText": "",
            "isVIP": true,
            "dieldState": "视频直播"

          },
          {
            "time": "11:00",
            "homeField": "",
            "awayField": "",
            "fieldText": "骑士vs尼克斯 赛后新闻发布会",
            "isVIP": false,
            "dieldState": "图文直播"

          },
          {
            "time": "12:00",
            "homeField": "",
            "awayField": "",
            "fieldText": "掘金vs森林狼 赛后新闻发布会",
            "isVIP": false,
            "dieldState": "视频直播"

          }
        ]
      }
    ],

    matchesList: [], // 赛程
    nowTime: ''
  },
  onLoad() {
    this.getNowTime()
    req('https://app.sports.qq.com/match/list?columnId=100000&flag=1&appvid=&date=' + this.data.nowTime).then(result => {
      this.setData({
        matchesList: result.data.data
      })
    })
  },


  methods: {

  },
  getNowTime() {
    var date = new Date();
    let Y = date.getFullYear() + '-';
    let M = (date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1) + '-';
    let D = date.getDate() + ' ';
    this.setData({
      nowTime: Y + M + D
    })
  },
  // 跳转到比赛详情界面
  gotoRaceDetails(e) {
    let mid = e.currentTarget.dataset.item.mid
    wx.redirectTo({
      url: '../raceDetails/raceDetails?mid=' + JSON.stringify(mid)
    })
  },
  // 点击加载更多
  add() {
    req('https://app.sports.qq.com/match/list?columnId=100000&appvid=&date=' + this.data.nowTime).then(result => {
      this.setData({
        matchesList: result.data.data
      })
    })
  }
})